package template

import (
	"fmt"
	"net/http"
)
import "html/template"

//	template的解析

func main() {
	// 1 启动http服务器
	http.HandleFunc("/hello", func(writer http.ResponseWriter, r *http.Request) {
		//1.
		t, err := template.ParseFiles("./hello.tmpl")
		if err != nil {
			fmt.Printf("error: %v", err)
			return
		}
		err = t.ExecuteTemplate(writer, ".", "王子")
		if err != nil {
			fmt.Printf("error: %v", err)
			return
		}

	})
	//2. 监听
	http.ListenAndServe(":9999", nil)
}
